package uk.co.penguinpower.yasl;

import android.app.Activity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.Spinner;

public class ListViewer extends Activity {
	Spinner cmbListStoreSelect;
	DBManager db;
	String list, store;
	
	@Override
    public void onCreate(Bundle savedInstanceState) { //Called when the activity is first created.
        super.onCreate(savedInstanceState);
        setContentView(R.layout.list_layout);
        
        db = new DBManager(this);
        
        //fill storez with store names and stick it in cmbNewListStore
		String storez[] = {};
		storez = db.getAllStores().toArray(storez);
        
		//get the selected list
		list = getIntent().getStringExtra("listname");
		
		int storeID = db.getListStoreID(list);
		
        ArrayAdapter<String> storezAdapter = new ArrayAdapter<String> (this, android.R.layout.simple_spinner_item, storez);
        cmbListStoreSelect = (Spinner) findViewById(R.id.cmbListStoreSelect);
        cmbListStoreSelect.setAdapter(storezAdapter);
        cmbListStoreSelect.setSelection(storeID);
        
	}
}